package com.hung.dao;

import com.hung.pojo.Comment;
import com.hung.util.orm.annotations.Delete;
import com.hung.util.orm.annotations.Insert;
import com.hung.util.orm.annotations.Select;

import java.util.List;

/**
 * 操作评论
 *
 * @author Hung
 */
public interface CommentDao {

    /**
     * 根据mid查询所有评论
     *
     * @param mid
     * @return
     */
    @Select("select mid,id,uid,comment from comment where mid = ?")
    List<Comment> queryAllCommentsByMid(Integer mid);

    /**
     * 根据id删除评论
     *
     * @param id
     * @return
     */
    @Delete("delete from comment where id= ?")
    Integer deleteCommentById(Integer id);

    /**
     * 保存评论
     *
     * @param comment
     * @return
     */
    @Insert("insert into comment (mid, id, uid, comment) VALUES (#{mid},default,#{uid},#{comment})")
    Integer addComment(Comment comment);
}
